import Vue from 'vue'
import App from './App.vue'
import router from './router'
import Router from 'vue-router'
import store from './store'
import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'url-search-params-polyfill'
import '@babel/polyfill'
import {
  XHeader,
  Swiper,
  SwiperItem,
  Tabbar,
  TabbarItem,
  Clocker,
  LoadingPlugin,
  AlertPlugin,
  ConfirmPlugin,
  ToastPlugin,
  PopupHeader,
  Popup,
  // Scroller,
  LoadMore,
  PopupPicker,
  Flow,
  FlowState,
  FlowLine,
  Actionsheet,
  Checklist,
  Rater,
  Checker,
  CheckerItem,
  Datetime,
  Confirm
// eslint-disable-next-line import/no-duplicates
} from 'vux'
import Chimage from './components/image'
import MallInfo from './components/mallinfo/mallinfo'
import AreaSelect from './components/areaSelect'
import globalData from './config/globalData'
import Navigation from 'vue-navigation'
import Scroller from './components/scroll-edit'

// eslint-disable-next-line import/no-duplicates
import { TransferDom } from 'vux'

Vue.use(LoadingPlugin)
Vue.use(AlertPlugin)
Vue.use(ConfirmPlugin)
Vue.use(ToastPlugin)

Vue.use(globalData)
Vue.use(Navigation, { router })
Vue.config.productionTip = false
Vue.component('XHeader', XHeader)
Vue.component('Swiper', Swiper)
Vue.component('swiper-item', SwiperItem)
Vue.component('chimage', Chimage)
Vue.component('mallinfo', MallInfo)
Vue.component('areaSelect', AreaSelect)
Vue.component('popup-header', PopupHeader)
Vue.component('popup', Popup)
Vue.component('load-more', LoadMore)
Vue.component('popup-picker', PopupPicker)
// Vue.component('scroller', Scroller)
Vue.component('flow', Flow)
Vue.component('flow-state', FlowState)
Vue.component('flow-line', FlowLine)
Vue.component('actionsheet', Actionsheet)
Vue.component('checklist', Checklist)
Vue.component('tabbar', Tabbar)
Vue.component('tabbar-item', TabbarItem)
Vue.component('clocker', Clocker)
Vue.component('rater', Rater)
Vue.component('checker', Checker)
Vue.component('checkerItem', CheckerItem)
Vue.component('datetime', Datetime)
Vue.component('confirm', Confirm)
Vue.component('scroller', Scroller)
Vue.use(VueAwesomeSwiper)

Vue.directive('transfer-dom', TransferDom)
// Vue.mixin({
//   beforeRouteLeave(to,from,next){
//     setTimeout(()=>{
//       console.log("离开时")
//       if(this.globalData.isBack){
//         this.globalData.isBack=false;
//         this.$destroy(from.name);
//       }
//       next()
//     },300)
//   },
// })
// eslint-disable-next-line no-unused-vars

// 解决 Uncaught (in promise) undefined
const routerPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return routerPush.call(this, location).catch(error => error)
}

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
